package com.todo.reward.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author azhebuxing
 * @date 2025/2/12 23:00
 * @description
 */
@Getter
@AllArgsConstructor
public enum RewardTypeEnum {

    COUPON(1, "WAIT_DISTRIBUTE", "优惠券"),
    RED_PACKET(2, "RED_PACKET", "红包"),
    POINTS(3, "POINTS", "积分"),
    GROWTH(4, "GROWTH", "成长值"),
    ;

    private static Map<Integer, RewardTypeEnum> typeMap = Arrays
            .stream(RewardTypeEnum.values())
            .collect(Collectors.toMap(RewardTypeEnum::getType, item -> item, (v1, v2) -> v2));

    private Integer type;
    private String code;
    private String name;


    public static RewardTypeEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
